package com.bs.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bs.model.OrderItem;
import com.bs.service.IOrderItemService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 说明：
 *
 * @author 琪
 * @since 2025/5/7 20:23
 */
@Service
@Slf4j
public class OrderItemServiceImpl extends ServiceImpl<BaseMapper<OrderItem>, OrderItem> implements IOrderItemService {

    @Override
    public boolean save(OrderItem entity) {
        entity.setCreateTime(new Date());
        entity.setUpdateTime(new Date());
        return super.save(entity);
    }

    @Override
    public boolean updateById(OrderItem entity) {
        entity.setUpdateTime(new Date());
        return super.updateById(entity);
    }

    @Override
    public List<OrderItem> listByOrderId(String id) {
        QueryWrapper<OrderItem> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("order_id", id);
        return list(queryWrapper);
    }
}